import { advancementMap } from "../../../hooks/useAdvancement"

export function getAdvancementDeclare(adMap: typeof advancementMap) {
  const map: Record<string, string> = {}

  let res = ``

  for (const [key, verObj] of adMap) {
    for (const ver of Object.keys(verObj)) {
      if (!map[ver]) map[ver] = ``
      map[ver] += `"${key}" | \n`
    }
  }

  for (const i in map) {
    res += `"${i}": ${map[i].substring(0, map[i].length - 4)};\n\n`
  }

  return res
}

export default function () {
  return `declare module "wiki:advancements" {\n export interface Advancements {\n \t${getAdvancementDeclare(advancementMap)} \n} \n} `
}